﻿using System;


namespace SH
{
    public enum shErrorCode
    {
        #region 错误码
        sh_ec_Begin                     = 0x2040000,      /// 错误代码起始编码

        sh_ec_Begin_Adapter             = sh_ec_Begin + 0x1000,
        sh_ec_Begin_NetAccess           = sh_ec_Begin + 0x2000,
        sh_ec_Begin_Router              = sh_ec_Begin + 0x3000,

        sh_ec_Success                   = 0,
        sh_ec_Failure                   = 1,
        //========================================================================
        /// 通用错误码定义
        /// 范围:0x01 - 0x3F
        sh_ec_Failed                    = sh_ec_Begin + 0x01, /// 一般性失败,原因未知
        sh_ec_Timeout                   = sh_ec_Begin + 0x02, /// 超时
        sh_ec_OutOfMemory               = sh_ec_Begin + 0x03, /// 内存不足
        sh_ec_NotActive                 = sh_ec_Begin + 0x04, /// 对象未激活
        sh_ec_IoPending                 = sh_ec_Begin + 0x05, /// IO等待中
        sh_ec_Overflow                  = sh_ec_Begin + 0x06, /// 溢出
        sh_ec_NotImplement              = sh_ec_Begin + 0x07, /// 未实现
        sh_ec_NotReady                  = sh_ec_Begin + 0x08, /// 未准备好
        sh_ec_NoInterface               = sh_ec_Begin + 0x0A, /// 没有该接口
        sh_ec_NullPointer               = sh_ec_Begin + 0x0B, /// 空指针
        sh_ec_InvalidHandle             = sh_ec_Begin + 0x0C, /// 无效句柄
        sh_ec_InvalidCommand            = sh_ec_Begin + 0x0D, /// 无效命令
        sh_ec_InvalidData               = sh_ec_Begin + 0x0E,/// 数据无效
        sh_ec_InvalidArgs               = sh_ec_Begin + 0x0F, /// 参数无效
        sh_ec_InvalidOperation          = sh_ec_Begin + 0x10, /// 非法操作
        sh_ec_WaitingForInit            = sh_ec_Begin + 0x11, /// 等待初始化
        sh_ec_AlreadyExist              = sh_ec_Begin + 0x12, /// 已经存在
        sh_ec_NotFound                  = sh_ec_Begin + 0x13, /// 没有找到
        sh_ec_Canceled                  = sh_ec_Begin + 0x14, /// 取消操作
        sh_ec_OperateBroken             = sh_ec_Begin + 0x15, /// 操作中断
        sh_ec_DeadLock                  = sh_ec_Begin + 0x16, /// 死锁
        sh_ec_Aborted                   = sh_ec_Begin + 0x17, /// 终止
        sh_ec_Retry                     = sh_ec_Begin + 0x18, /// 重试
        sh_ec_Duplicate                 = sh_ec_Begin + 0x19, /// 重复
        sh_ec_SystemError               = sh_ec_Begin + 0x1A, /// 系统错误
        sh_ec_NetworkError              = sh_ec_Begin + 0x1B, /// 网络错误
        sh_ec_LoadResourceFail          = sh_ec_Begin + 0x1C, /// 载入资源失败
        sh_ec_ModuleNotFound            = sh_ec_Begin + 0x1D, /// 模块未找到
        sh_ec_ServiceNotFound           = sh_ec_Begin + 0x1E, /// 服务未发现
        sh_ec_SizeTooLarge              = sh_ec_Begin + 0x1F, /// 太大
        sh_ec_SizeTooSmall              = sh_ec_Begin + 0x20, /// 太小
        sh_ec_BufferFull                = sh_ec_Begin + 0x21, /// 缓存满
        sh_ec_NoMoreData                = sh_ec_Begin + 0x22, /// 没有更多的数据
        sh_ec_ReadFileFaild             = sh_ec_Begin + 0x23, /// 读取文件失败
        sh_ec_FileCreateFaild           = sh_ec_Begin + 0x24, /// 文件创建失败
        sh_ec_DirCreateFaild            = sh_ec_Begin + 0x25, /// 目录创建失败
        sh_ec_FileNotExist              = sh_ec_Begin + 0x26, /// 文件不存在
        sh_ec_NotSupport                = sh_ec_Begin + 0x27, /// 不支持
        sh_ec_AlreadyActive             = sh_ec_Begin + 0x28, /// 已经激活，不能完成后续操作
        sh_ec_BufferLength              = sh_ec_Begin + 0x29, /// 缓存长度不正确
        sh_ec_InvalidStation            = sh_ec_Begin + 0x2A, /// 无效站点
        sh_ec_AlreadyConnected          = sh_ec_Begin + 0x2B, /// 已连接
        sh_ec_SerializeError            = sh_ec_Begin + 0x30, /// 序列化出错
        sh_ec_Busy                      = sh_ec_Begin + 0x31, /// 忙碌
        sh_ec_VeryBusy                  = sh_ec_Begin + 0x32, /// 非常忙碌
        sh_ec_ResourceUnavailable       = sh_ec_Begin + 0x33, /// 资源不可用
        sh_ec_NoSuchProcess             = sh_ec_Begin + 0x34, /// 没有这个进程
        sh_ec_AccessDenied              = sh_ec_Begin + 0x35, /// 访问拒绝
        sh_ec_InvalidUserOrPassword     = sh_ec_Begin + 0x36, /// 无效的用户名或密码
        sh_ec_UserNotLogon              = sh_ec_Begin + 0x37, /// 用户没有登录
        sh_ec_HasDestory                = sh_ec_Begin + 0x38, /// 已经销毁
        sh_ec_NotFoundRequest           = sh_ec_Begin + 0x39, /// 没有找到请求点
        sh_ec_LogOutFailed              = sh_ec_Begin + 0x3A, /// 登出失败
        sh_ec_LogOnFailed               = sh_ec_Begin + 0x3B, /// 登录失败

        sh_ec_InitialFailed             = sh_ec_Begin + 0x3D, /// 初始化失败
        sh_ec_LoadInterfaceFaild        = sh_ec_Begin + 0x3E, /// 加载接口函数失败
        sh_ec_Invalid_Cast              = sh_ec_Begin + 0x3F, /// 参数类型转换失败
        sh_ec_OutOfSpace                = sh_ec_Begin + 0x40, /// 超出范围
        sh_ec_InvalidDataType           = sh_ec_Begin + 0x41, /// 无效的数据类型
        sh_ec_MatchFaceing              = sh_ec_Begin + 0x42, /// 人脸比对中
        sh_ec_StatusChange              = sh_ec_Begin + 0x43, /// 状态变更
        sh_ec_NotNeedUpdate             = sh_ec_Begin + 0x44, /// 不需要更新
        sh_ec_ShiftNext                 = sh_ec_Begin + 0x45, /// 秘而不宣
        sh_ec_DeviceError               = sh_ec_Begin + 0x46, /// 设备信息错误

        sh_ec_NeedActive                = sh_ec_Begin_Adapter + 0x01, /// 需要激活	
        sh_ec_NeedBlock                 = sh_ec_Begin_Adapter + 0x02, /// 需要阻塞
        sh_ec_NeedSusspend              = sh_ec_Begin_Adapter + 0x03, /// 需要挂起
        sh_ec_Exiting                   = sh_ec_Begin_Adapter + 0x04, /// 退出中
        sh_ec_StationManager            = sh_ec_Begin_Adapter + 0x05, /// 站点管理器
        sh_ec_NotNeedSubscribe          = sh_ec_Begin_Adapter + 0x06, /// 不需要订阅
        sh_ec_NeedDestory               = sh_ec_Begin_Adapter + 0x07, /// 需要销毁
        sh_ec_WaitToDesroty             = sh_ec_Begin_Adapter + 0x08, /// 等待被销毁
        sh_ec_AccessIsNullptr           = sh_ec_Begin_Adapter + 0x09, /// 无效的访问器
        sh_ec_NotFoundStation           = sh_ec_Begin_Adapter + 0x0A, /// 没有找到站点
        sh_ec_NotFoundSession           = sh_ec_Begin_Adapter + 0x0B, /// 没有找到会话
        sh_ec_NotNeedCompress           = sh_ec_Begin_Adapter + 0x0C, /// 不需要压缩
        sh_ec_UnCompressError           = sh_ec_Begin_Adapter + 0x0D, /// 解压缩错误
        sh_ec_NoSendData                = sh_ec_Begin_Adapter + 0x0E, /// 没有要发送的数据
        sh_ec_NotNeedSubscrib           = sh_ec_Begin_Adapter + 0x0F, /// 没有要发送的数据
        sh_ec_Publishing                = sh_ec_Begin_Adapter + 0x10, /// 发布数据中
        sh_ec_NoBroker                  = sh_ec_Begin_Adapter + 0x11, /// 缺少Broker
        sh_ec_AddFinish                 = sh_ec_Begin_Adapter + 0x12, /// 添加完成 
        sh_ec_SerializeFailed           = sh_ec_Begin_Adapter + 0x13 ,/// 序列化失败 
        sh_ec_NotRegister               = sh_ec_Begin_Adapter + 0x14, /// 没有注册
        sh_ec_NoFacePhoto               = sh_ec_Begin_Adapter + 0x15, /// 没有人脸照片
        sh_ec_NoIdentitySN              = sh_ec_Begin_Adapter + 0x16, /// 缺失身份id
        sh_ec_ParseError                = sh_ec_Begin_Adapter + 0x16, /// 解析失败

        sh_ec_EmptyStatus               = sh_ec_Begin_Adapter + 0x18, /// Http返回的Json中“Status”字段为空
        sh_ec_EmptyResult               = sh_ec_Begin_Adapter + 0x19, /// Http返回的Json中“Result”字段为空
        sh_ec_EmptyData                 = sh_ec_Begin_Adapter + 0x1A, /// Http返回的Json中“Data”字段为空
        sh_ec_EmptyCode                 = sh_ec_Begin_Adapter + 0x1B, /// Http返回的Json中“Code”字段为空
        sh_ec_EmptyDeclareData          = sh_ec_Begin_Adapter + 0x1C, /// Http返回的Json中“DeclareData”字段为空

        //sh_is_net_errorT			T > sh_ec_Begin_NetAccess && T <=sh_ec_MaxNetError ? true: false
        sh_ec_ConnectFaild              = sh_ec_Begin_NetAccess + 0x01, ///连接失败
        sh_ec_NotConnected              = sh_ec_Begin_NetAccess + 0x02, ///未连接
        sh_ec_WaitAutoConnet            = sh_ec_Begin_NetAccess + 0x03 ,///等待自动重连，此时还未连接成功
        sh_ec_RequestTimeOut            = sh_ec_Begin_NetAccess + 0x04, ///请求超时
        sh_ec_ConnectTimeOut            = sh_ec_Begin_NetAccess + 0x05, ///连接超时
        sh_ec_AdapterNotActive          = sh_ec_Begin_NetAccess + 0x06 ,///适配器未激活
        sh_ec_UseOneWay                 = sh_ec_Begin_NetAccess + 0x07 ,///使用oneway
        sh_ec_UseTwoWay                 = sh_ec_Begin_NetAccess + 0x08, ///使用twoway
        sh_ec_FinishConnect             = sh_ec_Begin_NetAccess + 0x09 ,///关闭连接
        sh_ec_TransDamageed             = sh_ec_Begin_NetAccess + 0x0A, ///传输器已损坏
        sh_ec_HeaderCheck               = sh_ec_Begin_NetAccess + 0x0B ,///协议头部错误
        sh_ec_BadMagic                  = sh_ec_Begin_NetAccess + 0x0C, ///坏的magic
        sh_ec_UnacceptableProtocol      = sh_ec_Begin_NetAccess + 0x0D ,///不接受的协议
        sh_ec_ObjectNotFind             = sh_ec_Begin_NetAccess + 0x0E ,///对象为找到
        sh_ec_ObjectNameExist           = sh_ec_Begin_NetAccess + 0x0F, ///对象已存在
        sh_ec_UnSupportedFunction       = sh_ec_Begin_NetAccess + 0x10, ///不支持的功能
        sh_ec_UnSupportedInterface      = sh_ec_Begin_NetAccess + 0x11, ///不支持的接口
        sh_ec_ListenAddr                = sh_ec_Begin_NetAccess + 0x12 ,///监听地址打开错误
        sh_ec_ReuseContext              = sh_ec_Begin_NetAccess + 0x13, ///重用context
        sh_ec_FreeContext               = sh_ec_Begin_NetAccess + 0x14 ,///回收context
        sh_ec_NoRequest                 = sh_ec_Begin_NetAccess + 0x15 ,///缺少请求体
        sh_ec_NoResponse                = sh_ec_Begin_NetAccess + 0x16, ///缺少响应体
        sh_ec_NoService                 = sh_ec_Begin_NetAccess + 0x17, ///缺少网络服务
        sh_ec_PacketError               = sh_ec_Begin_NetAccess + 0x18, ///包数据错误 

        #endregion
    }

    public class shErrorCodeUtilt
    {
        /// 是否为成功状态码。
        public static bool IsSuccess(shErrorCode ec)
        {
            return ec == shErrorCode.sh_ec_Success;
        }


    }
}
